SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
-- =============================================
-- Author:		<Martín Peveri>
-- Create date: <07/02/2012>
-- Description:	<Reporte Lista de Precios>
-- =============================================
CREATE PROCEDURE [dbo].[listprecio_report]
	-- Add the parameters for the stored procedure here
	@id_articulo_desde char,
	@id_articulo_hasta char,
	@codigo_desde char,
	@codigo_hasta char,
	@id_entProv_desde char,
	@id_entProv_hasta char,
	@id_usuario_desde char,
	@id_usuario_hasta char,
	@id_categ_entidad_desde char,
	@id_categ_entidad_hasta char,
	@id_entCom_desde char,
	@id_entCom_hasta char

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	select a.*, b.*
	from App_articulo a
		JOIN App_desrec b on a.id_articulo = b.id_articulo
		JOIN App_lista c on b.id_lista = c.id_lista
		JOIN App_entidad d on b.id_entidad = d.id_entidad
	where c.id_lista BETWEEN @id_articulo_desde AND @id_articulo_hasta and
		c.codigo BETWEEN @codigo_desde AND @codigo_hasta and
		a.id_entidad BETWEEN @id_entProv_desde AND @id_entProv_hasta and
		c.id_usuario BETWEEN @id_usuario_desde AND @id_usuario_hasta and
		c.id_categ_entidad BETWEEN @id_categ_entidad_desde AND @id_categ_entidad_hasta and
		d.id_entidad BETWEEN @id_entCom_desde AND @id_entCom_hasta AND
		d.id_perfil = 'C' 
	ORDER BY a.id_articulo
END
GO
